package com.heima.freemarker.controller;

import com.heima.article.controller.v1.ArticleHomeController;
import com.heima.freemarker.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class HelloController {


    @GetMapping("testFreeMarker")
    public String hello(Model model) {
        Student student = new Student();
        student.setName("哭戏蒂尼");
        student.setAge(36);
        //对01-basic文件中的插值进行赋值
        model.addAttribute("name", "test");
        model.addAttribute("stu", student);
        return "01-basic";
    }

    //生成集合
    @GetMapping("testList")
    public String list(Model model) {
        List<Student> studentList = new ArrayList<>();
        Student student = new Student();
        student.setName("哭戏蒂尼");
        student.setAge(36);
       // student.setMoney(114514F);
        studentList.add(student);
        model.addAttribute("stus", studentList);

        Map<String, Student> stuMap = new HashMap<>();
        stuMap.put("stu1", student);
        stuMap.put("stu2", student);
        model.addAttribute("stuMap", stuMap);
        //长数值
        model.addAttribute("point",1145141919810L);
        return "02-list";
    }
}
